
$(function (){
    $.post($("#hidden_info").attr("rel")+"/CException/findAll",{},function (data){
        var table = $("#table");
        for(var i=0;i<data.length;i++){
            table.append("<tr><td>"+data[i].eid
                +"</td><td>"+data[i].exceptionType
                +"</td><td>"+data[i].exceptionInfo
                +"</td><td><a href='exp_update.jsp?id="
                +data[i].eid
                +"'"
                +" class='update_btn btn btn-primary'>修改</a>&nbsp;&nbsp;<button class='btn btn-danger delete_btn'>删除</button></td></tr>");
        }

        $(".delete_btn").click(function() {
            var row = $(this).closest("tr");
            var val = row.find("td:eq(0)").text();
           $.post($("#hidden_info").attr("rel")+"/CException/delete",{id:val},function (data){
                if(data.flag){
                    location.href = "exp_con.jsp";
                }else{
                    alert("删除失败！");
                }
                return false;
           });
           return false;
        });
    });

    $("#i_btn").click(function (){

        $.post($("#hidden_info").attr("rel")+"/CException/save",$("#insert").serialize(),function (data){
            if(data.flag){
                location.href = "exp_con.jsp";
            }else{
                alert("新增失败！");
            }
            return false;
        });
        return false;
    });

});

